package com.qzsf.backend.service.impl;

import com.qzsf.backend.common.Result;
import com.qzsf.backend.mapper.EventMapper;
import com.qzsf.backend.mapper.UserAuthMapper;
import com.qzsf.backend.service.DashboardService;
import com.qzsf.backend.vo.DashboardStatsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/*
 * @Author: Dennis Chen
 * @CreateTime: 2024/11/27 1:15 周三
 * @Email 1429278462@qq.com
 * @Remark 管理员统计数据查看服务层实现类
 * @Version 1.0
 */
@Service
public class DashboardServiceImpl implements DashboardService {
    @Autowired
    private EventMapper eventMapper;
    @Autowired
    private UserAuthMapper userAuthMapper;
    @Override
    public Result getStats() {

        int volunteers = userAuthMapper.getUserNum();
        int upcomingEvents = eventMapper.getUpcomingEvents();
        int completedEvents = eventMapper.getCompletedEvents();
        DashboardStatsVO dashboardStatsVO = new DashboardStatsVO(volunteers,upcomingEvents,completedEvents);
        return Result.success(dashboardStatsVO);
    }
}
